#!/usr/bin/perl
use strict;
use warnings;
use CGI ();

#use CGI::Carp qw(fatalsToBrowser);
use MIME::Lite ();
use Country;
use Storable qw(lock_store);


while (my $line = <>) {
	chomp $line;
	if ($line =~ /^([A-Z]{2})\b\s*([^\d]+?)\s*\b(\d{4})\b.*$/) {
		my $code = $1;
		my $display_text = $2;
		my $year = $3;
		
		my $p = Country->new('id' => $code, 'name' => $display_text, 'ISO_3166_1_year' => $year);
		my $rv = $p->load('speculative' => 1);
		if (!$rv) {
			$p->save();
		}
	}
}
